<template>
<h1>猜数字练习</h1>
  <input v-model="num" type="text" placeholder="请输入一个1-100知己难得数字">
  <button @click="check()">猜数字</button>
  <h3>结果为:{{result}}</h3>
</template>


<script setup>
 import {ref} from "vue";

 const num = ref('');
 const result = ref('');
//  生成一个1-100之间的随机数
 const x = parseInt(Math.random()*100+1) ;
 let num1 = 0;
 console.log('打个小抄'+x);
 const check=()=>{
   num1++;
   if (num.value>x){
     result.value='猜大了'
   } else if (name.value<x){
     result.value='猜小了'
   } else {
     result.value="猜对了"
   }


 }

</script>

<style scoped>

</style>